package classes;

public class Espai{

	private String nom;
	private Calendari cal;
	
	
	public Espai(String nom) {
		super();
		this.nom = nom;
		this.cal = new Calendari();
	}
	public Espai(String nom, Calendari cal) {
		super();
		this.nom = nom;
		this.cal = cal;
	}


	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public void assignarCalendari(Calendari cal){
		if(this.cal.getLlistaAnys().isEmpty()){
			this.cal=cal;
		}else{
			this.cal.merge(cal);
		}
		
	}
	public void substituirCalendari(Calendari cal){
			this.cal=cal;
		
	}


	public Calendari getCal() {
		return cal;
	}
	
	
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "Espai" + nom;
	}
	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		return ((((Espai)obj).nom).equals(this.nom));
	}
	public void merge(Espai auxEspai) {
		this.getCal().merge(auxEspai.getCal());
		
	}
	
	
}
